﻿#include "messagetip.h"

TMessageTip::TMessageTip(const QString &msg, QWidget *parent) : QDialog(parent)
{

    labMsg = new QLabel();
    labMsg->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    labMsg->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    labMsg->setStyleSheet("color: #FFF;");
    labMsg->setText(msg);

    QVBoxLayout *layout = new QVBoxLayout();
    layout->setMargin(15);
    layout->setSpacing(0);
    layout->addWidget(labMsg);
    this->setLayout(layout);

    this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowStaysOnTopHint);
    this->setStyleSheet("background:#1c2239;");
    this->setWindowTitle("提示");
    this->resize(100, 40);

    timer = new QTimer();
    timer->singleShot(1500, this, &TMessageTip::OnTimer);
}

TMessageTip::~TMessageTip()
{
    delete labMsg;
    delete timer;
}

void TMessageTip::OnTimer(){
    this->close();
}
